document.addEventListener('DOMContentLoaded', function() {
	setTimeout(function () {
		if (window.templateId) {
			function clickEvent (statisticBtn, userId) {
				statisticBtn.addEventListener('click', () => {
					// 请求个人数据，打开个人页面
					var url = '/seeyon/relocationDataControl.do?method=showPersonRelocation&user_id=' + userId;
					var screenWidth = screen.width;
					var screenHeight = screen.height;
					var windowFeatures = "location=no,menubar=no,status=no,toolbar=no,resizable=yes,width=" + screenWidth + ",height=" + screenHeight;
					var newWindow = window.open(url, '_blank', windowFeatures);
					if (newWindow) {
						newWindow.moveTo(0, 0);
					}
				});
			}
			// 发送请求判断是否需要显示"Mobilization Record出勤记录按钮"
			$.get('/seeyon/relocationDataControl.do?method=checkRelocation', {
			  	templateId: window.templateId
			})
			.done(function(res) {
				var linkElement = document.createElement("link");
				linkElement.href = "/seeyon/apps_res/collaboration/css/ebs.css"; // CSS 文件的路径
				linkElement.type = "text/css";
				linkElement.rel = "stylesheet";
				document.head.appendChild(linkElement);
				if (res.data) {
					var iconStr = '<a class="toolBtn" style="font-size:12px;border: 1px solid;color: rgba(62, 160, 254, 1);" id="statisticBtn" onmouseenter="null" onmouseleave="null" onmouseover="null" onmouseout="null"><span class="menu_span" title="Mobilization Record">Mobilization Record</span></a>';
					var waitSendBtn = document.querySelector('#print_a');
					waitSendBtn.insertAdjacentHTML('afterEnd', iconStr);
					var statisticBtn = document.getElementById('statisticBtn');
					clickEvent(statisticBtn, res.userId);
				}
			})
		}
	}, 500);
})